package com.vert.service;

import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.json.JsonObject;
import io.vertx.ext.web.RoutingContext;

import java.util.HashMap;
import java.util.Map;

/**
 * @Classname TicketService
 * @Description TODO
 * @Date 2022/5/24 14:36
 * @Created by XiongXiong
 * @Author: X.I.O
 */
public class TicketService {



  public void handleGetTicketPrice(RoutingContext routingContext) {
    JsonObject reqDate = routingContext.getBodyAsJson();
    HttpServerResponse response = routingContext.response();
    if (reqDate == null) {
      sendError(400, response);
    } else {
      JsonObject object=new JsonObject();
      object.put("code",1);
      routingContext.response().putHeader("content-type", "application/json; charset=utf-8")
        .end(object.toString());
    }
  }

  public void hadlerObj(RoutingContext routingContext,Object obj){
    JsonObject reqDate = routingContext.getBodyAsJson();
    HttpServerResponse response = routingContext.response();
    if (reqDate == null) {
      sendError(400, response);
    } else {
      JsonObject object=new JsonObject();
      object.put("code",obj);
      routingContext.response().putHeader("content-type", "application/json; charset=utf-8")
        .end(object.toString());
    }
  }



  private void sendError(int statusCode, HttpServerResponse response) {
    response.setStatusCode(statusCode).end();
  }

}
